include:
  - pkg.pkg-init
  - user.www
pcre-install:
  file.managed:
    - name: /usr/local/src/pcre-8.41.tar.gz
    - source: salt://apache/files/pcre-8.41.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && sudo tar xf pcre-8.41.tar.gz && cd pcre-8.41 && sudo ./configure --prefix=/usr/local/pcre-8.41 && sudo make && sudo make install
    - unless: test -d /usr/local/pcre-8.41
    - require:
      - file: pcre-install
apr-install:
  file.managed:
    - name: /usr/local/src/apr-1.6.3.tar.gz
    - source: salt://apache/files/apr-1.6.3.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && sudo tar xf apr-1.6.3.tar.gz && cd apr-1.6.3 && sudo ./configure --prefix=/usr/local/apr && sudo make && sudo make install
    - unless: test -d /usr/local/apr
    - require:
      - file: apr-install
apr-util-install:
  file.managed:
    - name: /usr/local/src/apr-util-1.6.1.tar.gz
    - source: salt://apache/files/apr-util-1.6.1.tar.gz
    - user: root
    - group: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && sudo tar xf apr-util-1.6.1.tar.gz && cd apr-util-1.6.1 && sudo ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && sudo make && sudo  make install
    - unless: test -d /usr/local/apr-util
    - require:
      - file: apr-util-install
      - cmd: apr-install
apache24-install:
  file.managed:
    - name: /usr/local/src/http-2.4.29.tar.gz
    - source: salt://apache/files/httpd-2.4.29.tar.gz
    - user: root
    - gourp: root
    - mode: 755
  cmd.run:
    - name: cd /usr/local/src && sudo tar xf http-2.4.29.tar.gz && cd httpd-2.4.29 && sudo ./configure --prefix=/usr/local/httpd24/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre-8.41/ --with-zlib --with-pcre --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-zlib --enable-deflate  --enable-modules=most --enable-mpms-shared=all --with-mpm=worker -enable-modules=all && sudo make && sudo make install
    - unless: test -d /usr/local/httpd24 
    - require:
      - file: apache24-install
      - cmd: apr-install
      - cmd: apr-util-install
      - cmd: pcre-install
